#include<bits/stdc++.h>
using namespace std;
int n;
const int N = 1e6+10;
vector<int> bian[N];
int siz[N];
int fath[N];
vector<int> ss[N];
void dfs(int x,int fa){
    siz[x] = 1;
    fath[x] = fa;
    for(int v : bian[x]){
        if(v == fa){
            continue;
        }
        dfs(v,x);
        ss[x].push_back(siz[v]);
        siz[x] += siz[v];
    }
}
inline bool chk(int blo){
    for(int i = 1;i<=n;i++){
        int ts = 1;
        for(int v : ss[i]){
            ts += v % blo;
        }
        if(ts > blo){
            return false;
        }
    }
    return true;
}
int main(){
    scanf("%d",&n);
    for(int i = 1;i < n;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        bian[u].push_back(v);
        bian[v].push_back(u);
    }
    dfs(1,0);
    int cnt = 0;
    for(int i = 1;1ll*i*i <= n;i++){
        if(n % i == 0){
            cnt += chk(i);
            if(n / i != i){
                cnt += chk(n/i);
            }
            //cerr<<i<<' '<<n/i<<'\n';
        }
    }
    cout<<cnt<<'\n';
}